<template>
  <boss-view>
    <div slot="head">
      <head-view @modalShow="modalShow">
        <span slot="title" class="title">高层驾驶舱</span>
      </head-view>
    </div>
    <div slot="content" class="content home">
      <!-- 集团 -->
      <div @click="pushRouterFun('/jituan')">
        <view-item>
          <img slot="itemData" class="logo" src="../../static/img/bossVersion/logo1.png">
        </view-item>
      </div>
      <!-- 板块 -->
      <div class="plate">
        <!-- 地产 -->
        <div class="plateItem" @click="pushRouterFun('/dc')">
          <view-item>
            <img src="../../static/img/bossVersion/logo2.png" slot="itemData" class="logo">
          </view-item>
        </div>
        <!-- 产业园 -->
        <div class="plateItem" @click="pushRouterFun('/cyy')">
          <view-item>
            <img src="../../static/img/bossVersion/logo3.png" slot="itemData" class="logo">
          </view-item>
        </div>
        <!-- 钢圈 -->
        <div class="plateItem" @click="pushRouterFun('/gq')">
          <view-item>
            <img src="../../static/img/bossVersion/logo4.png" slot="itemData" class="logo">
          </view-item>
        </div>
        <!-- 房联行 -->
        <div class="plateItem" @click="pushRouterFun('/flh')">
          <view-item>
            <img src="../../static/img/bossVersion/logo5.png" slot="itemData" class="logo flh">
          </view-item>
        </div>
        <!-- 金控 -->
        <div class="plateItem" @click="messageFun">
          <view-item>
            <img src="../../static/img/bossVersion/logo6.png" slot="itemData" class="logo">
          </view-item>
        </div>
        <!-- 融媒 -->
        <div class="plateItem" @click="messageFun">
          <view-item>
            <img src="../../static/img/bossVersion/logo7.png" slot="itemData" class="logo">
          </view-item>
        </div>
      </div>
    </div>
    <div slot="modal">
      <modal v-if="showModal" @modalShow="modalShow">
        <div slot="modalContent" class="modalContent">
          <el-form
            class="card-box login-form"
            autocomplete="off"
            :model="loginForm"
            :rules="loginRules"
            ref="loginForm"
            label-position="left"
          >
            <h3 class="tit">请先登录</h3>
            <div class="loginInput">
              <el-form-item prop="username">
                <img src="../../static/img/bossVersion/login1.png" alt>
                <el-input
                  name="username"
                  type="text"
                  v-model="loginForm.username"
                  autocomplete="off"
                  placeholder="请输入用户名"
                />
              </el-form-item>

              <el-form-item prop="password">
                <img src="../../static/img/bossVersion/login2.png" alt>
                <el-input
                  name="password"
                  :type="pwdType"
                  @keyup.enter.native="handleLogin"
                  v-model="loginForm.password"
                  autocomplete="off"
                  placeholder="请输入密码"
                />
              </el-form-item>
              <main-block></main-block>
            </div>
            <div class="loginBtn">
              <el-button type="primary" :loading="loading" @click.native.prevent="handleLogin">登录</el-button>
              <main-block></main-block>
            </div>
          </el-form>
        </div>
      </modal>
    </div>
  </boss-view>
</template>

<script>
// import { setToken, setTokenName } from "@/utils/auth";
// import { loginUrl } from "@/api/keyJob/index";
import mainBlock from "@/components/bossVersion/mainBlock";
import viewItem from "@/components/bossVersion/viewItem";
import headView from "@/components/bossVersion/headView";
import bossView from "@/components/bossVersion/bossView";
import modal from "@/components/modal/modal";
export default {
  components: {
    mainBlock,
    modal,
    viewItem,
    headView,
    bossView
  },
  data() {
    return {
      showModal: false,
      loginForm: {
        username: "",
        password: ""
      },
      loginRules: {
        //      username: [{ required: true, trigger: 'blur', validator: validateUsername }],
        //      password: [{ required: true, trigger: 'blur', validator: validatePassword }]
      },
      pwdType: "password",
      loading: false
    };
  },
  mounted() {},
  methods: {
    messageFun() {
      this.$message("努力开发中...");
    },
    modalShow(p) {
      this.$set(this, "showModal", p);
    },
    pushRouterFun(path) {
      this.$router.push({
        path: path
      });
    },
    async login() {
      //   try {
      //     var d = {
      //       LoginName: this.loginForm.username,
      //       Pwd: this.loginForm.password
      //     };
      //     var res = await loginUrl(d);
      //     if (res.data.code === "1") {
      //       var data = this.$utils.getUserInfo(d.LoginName);
      //       var roles = [];
      //       roles.push(data.role);
      //       this.$store.dispatch("GenerateRoutes", { roles }).then(() => {
      //         // 生成可访问的路由表
      //         this.$router.addRoutes(this.$store.getters.addRouters); // 动态添加可访问路由表
      //         // hack方法 确保addRoutes已完成
      //       });
      //       //   setToken(data.token);
      //       //   setTokenName(data.name);
      //       this.$store.commit("SET_ROLES", data.role);
      //       this.$store.commit("SET_NAME", data.name);
      //       this.$store.commit("SET_UERINFO", this.loginForm);
      //       this.$store.commit("SET_TOKEN", data.token);
      //       this.$store.commit("SET_AVATAR", data.avatar);
      //       this.$store.commit("SET_INTRODUCTION", data.introduction);
      //       this.loading = false;
      //       this.$message({
      //         message: "登陆成功",
      //         type: "success",
      //         duration: 1000
      //       });
      //       this.$router.push({ path: "/" });
      //     } else {
      //       this.loading = false;
      //       this.$message({
      //         message: res.data.msg,
      //         type: "error",
      //         duration: 1000
      //       });
      //     }
      //   } catch (error) {
      //     console.log(error);
      //     this.loading = false;
      //   }
    },
    handleLogin() {
      this.$refs.loginForm.validate(valid => {
        if (valid) {
          this.login();
        } else {
          console.log("error submit!!");
          return false;
        }
      });
    }
  }
};
</script>
<style lang="scss">
@import "../style/bossVersion/_basics";
.modalContent {
  .tit {
    margin-bottom: 0.22rem;
    color: $color1;
    text-align: center;
    font-size: 0.2rem;
    line-height: 1;
  }
  .loginInput {
    position: relative;
    z-index: 1;
    height: 0.9rem;
    margin-bottom: 0.3rem;
    padding: 0 0.1rem;
    background-color: rgba(0, 0, 0, 0.7);
    @include borderAll;
    & > .el-form-item {
      margin-bottom: 0;
      &:nth-of-type(1) {
        border-bottom: 1px solid $color9;
      }
      .el-input__inner {
        color: $color1;
        font-size: 0.14rem;
        height: 0.2rem;
        line-height: 0.2rem;
        background-color: transparent;
        border: none;
        &::-webkit-input-placeholder {
          color: rgba($color1, 0.4);
        }
      }
    }
    .el-form-item__content {
      @include flexYcen;
      height: 0.45rem;
      line-height: initial;
      font-size: 0.15rem;
      img {
        width: auto;
        height: auto;
        max-width: 0.2rem;
        max-height: 0.2rem;
      }
    }
  }
  // 按钮
  .loginBtn {
    position: relative;
    z-index: 1;
    width: 100%;
    height: 0.45rem;
    background-color: rgba(0, 0, 0, 0.7);
    @include borderAll;
    .el-button--primary {
      width: 100%;
      height: 100%;
      padding: 0;
      margin-bottom: 0;
      color: $color1;
      @include bold(0.17rem);
      background-color: transparent;
      border: none;
    }
  }
}
</style>

<style lang="scss" scoped>
@import "../style/bossVersion/_basics";

.home {
  @include absoluteAllSides(0.58, 0, 0, 0, 1);
  padding: 0.1rem;
  overflow-y: scroll;
  .item {
    @include flexXYcen;
    width: 100%;
    height: 1.35rem;
    & > img {
      width: auto;
      height: auto;
      max-width: 0.88rem;
      max-height: 0.5rem;
    }
    & > .flh {
      max-width: 1.08rem;
    }
  }
  .plate {
    @include flexFlow;
    margin-top: 0.1rem;
    & > .plateItem {
      width: 1.72rem;
      height: 1.4rem;
      &:nth-child(2n + 1) {
        margin-right: 0.1rem;
      }
      &:nth-child(-n + 4) {
        margin-bottom: 0.1rem;
      }
      & > .item {
        height: 1.4rem;
      }
    }
  }
}
</style>
